<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>非单文件组件</title>
    <script type="text/javascript" src="./js/vue.js"></script>
    <script src="./js/dayjs.min.js"></script>
    <style>
        body {
            padding: 10px;
        }

        input {
            margin: 5px;
        }
    </style>
</head>
<div id="root">
    <hello></hello>
    <hr>
    <school></school>
    <hr>
    <xuesheng></xuesheng>
</div>
<div id="root2">
    <hello></hello>
</div>
<script type="text/javascript">
    Vue.config.productionTip = false;
    
    const student = Vue.extend({
        template:`
        <div>
            <h2>学生姓名:{{studentName}}</h2>
            <h2>学生年龄:{{age}}</h2>
        </div>
        `,
        data() {
            return {
                studentName: '李希明',
                age: 18,
            };
        }
    });
    
    const school = Vue.extend({
        template:`
        <div>
            <h2>学校名称:{{schoolName}}</h2>
            <h2>学校地址:{{address}}</h2>
            <button @click="showName">点我提示学校</button>
            <student></student>
        </div>
        `,
        data() {
            return {
                schoolName: '培立优',
                address: '三箭银苑B',
            };
        },
        methods:{
            showName(){
                alert(this.schoolName);
            }
        },
        components:{
            student
        }
    });

    const hello = {
        template: `
        <div>
            <h1>你好啊</h1>
        </div>
        `,
    };
    // 全局组件
    Vue.component('hello', hello);

    const vm = new Vue({
        el: '#root',
        data: {
            msg: '你好啊'
        },
        //#region 
        computed: {
        },
        methods: {
        },
        // 注册组件
        components: {
            school: school,
            xuesheng: student,
        }
    });

    const vm2 = new Vue({
        el: '#root2',
    });
</script>

</html>